home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / wasm223.zip / CHECK4.ASM < prev    next >
Assembly Source File  |  1993-05-04  |  1KB  |  57 lines

  1. ;*************************************;
  2. ; WASM Checksum Calculation, CRC Byte ;
  3. ; By Eric Tauck                       ;
  4. ;                                     ;
  5. ; Defines:                            ;
  6. ;                                     ;
  7. ;   CrcRes  reset CRC                 ;
  8. ;   CrcCur  return current CRC        ;
  9. ;   CrcUpd  update current CRC        ;
  10. ;*************************************;
  11.  
  12.         jmps    _check4_end
  13.  
  14. ;--- data
  15.  
  16. _crc_cur        DW      0       ;current checksum value
  17.  
  18. ;========================================
  19. ; Reset CRC.
  20.  
  21. CrcRes  PROC    NEAR
  22.         mov     _crc_cur, 0     ;zero checksum
  23.         ret
  24.         ENDP
  25.  
  26. ;========================================
  27. ; Return the current CRC.
  28. ;
  29. ; Out: AX= CRC value.
  30.  
  31. CrcCur  PROC    NEAR
  32.         mov     ax, _crc_cur    ;return checksum
  33.         ret
  34.         ENDP
  35.  
  36. ;========================================
  37. ; Update the current CRC by a byte.
  38. ;
  39. ; In: AL= byte.
  40.  
  41. CrcUpd  PROC    NEAR
  42.         mov     dl, al
  43.         mov     ax, _crc_cur    ;current CRC
  44.         mov     cx, 8           ;bits to update
  45.  
  46. _ccupd1 shl     dl              ;shift bit
  47.         rcl     ax              ;roll into checksum
  48.         jnc     _ccupd2         ;skip xor if bit not shifted out
  49.         xor     ax, 1021H       ;xor CRC value
  50. _ccupd2 loop    _ccupd1         ;loop for each bit
  51.  
  52.         mov     _crc_cur, ax    ;save
  53.         ret
  54.         ENDP
  55.  
  56. _check4_end
  57.